import React, { Component } from 'react'
// import qs from 'querystring'
const data = [
  {id: 1, content: 'hello'},
  {id: 2, content: 'how are you'},
  {id: 3, content: 'fine thank you'},
]
export default class Detail extends Component {
  render() {
    // params参数的接收
    // let {id, title} = this.props.match.params
    // id = parseInt(id)
    // console.log(this.props);

    // search参数的接收
    // const search = qs.parse(this.props.location.search.split('?')[1])
    // const id = parseInt(search.id)
    // const title = search.title

    // state参数的接收
    const {id, title} = this.props.location.state
    console.log(this.props);

    return (
      <div>
        <ul>
          <li>Id: {id}</li>
          <li>Title: {title}</li>
          <li>Content: {
            (data.find(item => item.id===id))?.content
            }</li>
        </ul>
      </div>
    )
  }
}
